import axios from './axios'
import qs from 'qs'
import { baseUrl } from '@/config/config'
// 获取博客分类列表
export const blogCategoryGet = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/blog/categorys',
      method: 'GET',
      params
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 新增博客分类
export const blogCategoryPost = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/blog/category',
      method: 'POST',
      headers: {
        'Content-Type': 'application/json; charset=utf-8' 
      },
      data: JSON.stringify(params)
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 修改博客分类
export const blogCategoryPut = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/blog/category/' + params.id,
      method: 'PUT',
      headers: {
        'Content-Type': 'application/json; charset=utf-8' 
      },
      data: JSON.stringify(params)
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 删除博客分类
export const blogCategoryDelete = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/blog/category/' + params.id,
      method: 'Delete',
      headers: {
        'Content-Type': 'application/json; charset=utf-8' 
      },
      data: JSON.stringify(params)
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 获取博客评论列表
export const commentGet = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/comments',
      method: 'GET',
      params
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 删除博客评论
export const commentDelete = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/comment/' + params.id,
      method: 'Delete',
      headers: {
        'Content-Type': 'application/json; charset=utf-8' 
      },
      data: JSON.stringify(params)
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 获取博客分类列表
export const articleGet = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/articles',
      method: 'GET',
      params
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 新增博客分类
export const articlePost = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/article',
      method: 'POST',
      headers: {
        'Content-Type': 'application/json; charset=utf-8' 
      },
      data: JSON.stringify(params)
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 修改博客分类
export const articlePut = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/article/' + params.id,
      method: 'PUT',
      headers: {
        'Content-Type': 'application/json; charset=utf-8' 
      },
      data: JSON.stringify(params)
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 删除博客分类
export const articleDelete = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/article/' + params.id,
      method: 'Delete',
      headers: {
        'Content-Type': 'application/json; charset=utf-8' 
      },
      data: JSON.stringify(params)
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 获取书签列表
export const siteGet = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/blog/sites',
      method: 'GET',
      params
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 新增博客分类
export const sitePost = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/site',
      method: 'POST',
      headers: {
        'Content-Type': 'application/json; charset=utf-8' 
      },
      data: JSON.stringify(params)
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 修改博客分类
export const sitePut = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/site/' + params.id,
      method: 'PUT',
      headers: {
        'Content-Type': 'application/json; charset=utf-8' 
      },
      data: JSON.stringify(params)
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 删除博客分类
export const siteDelete = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/site/' + params.id,
      method: 'Delete',
      headers: {
        'Content-Type': 'application/json; charset=utf-8' 
      },
      data: JSON.stringify(params)
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 获取书签分类列表
export const blogSiteCategoryGet = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/blog/site/categorys',
      method: 'GET',
      params
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 新增书签分类
export const blogSiteCategoryPost = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/blog/site/category',
      method: 'POST',
      headers: {
        'Content-Type': 'application/json; charset=utf-8' 
      },
      data: JSON.stringify(params)
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 修改书签分类
export const blogSiteCategoryPut = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/blog/site/category/' + params.id,
      method: 'PUT',
      headers: {
        'Content-Type': 'application/json; charset=utf-8' 
      },
      data: JSON.stringify(params)
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
// 删除书签分类
export const blogSiteCategoryDelete = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/blog/site/category/' + params.id,
      method: 'Delete',
      headers: {
        'Content-Type': 'application/json; charset=utf-8' 
      },
      data: JSON.stringify(params)
    }).then(res => {
      resolve(res.data)
    }).catch(error => {
      reject(error.data)
    })
  })
}
